	<jsp:include page="commonjsp/header.jsp"></jsp:include>
		<div class="visitor-info">
				<h3>Add Tour</h3>
			</div>
		<div class="content">
			<div class="form">
				<form action="searchtour.jsp" method="post" id="input_form" name="formRegister"
				onsubmit="return checkAll();">
				<div class="row">
						<div class="col1">
							<p>Tour name :</p>
						</div>
						<div class="col2">
							<input type="text" name="tourName" id="tourName"/>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>Places :</p>
						</div>
						<div class="col2">
							<input type="text"  name="places" id="places"/>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>Start Date:</p>
						</div>
						<div class="col2">
							<input type="text" name="startDate" id="startDate"/>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>End Date :</p>
						</div>
						<div class="col2">
							<input type="text" name="endDate" id="endDate"/>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>Price :</p>
						</div>
						<div class="col2">
							<input type="text" name="places"/>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>Image :</p>
						</div>
						<div class="col2">
							<input type="text" name="images"/>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>Number of visitors :</p>
						</div>
						<div class="col2">
							<input type="text" name="maxVisitors"/>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>Number of current visitors :</p>
						</div>
						<div class="col2">
							<input type="text" name="currentVisitors"/>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>Description :</p>
						</div>
						<div class="col2">
							<textarea name="description" rows="6" cols="30">
								
							</textarea>
						</div>
					</div>
					<div class="row">
						<div class="col1">
							<p>Tag :</p>
						</div>
						<div class="col2 area">
							<input type="text" name="currentVisitors"/>
						</div>
						<div class="clear"></div>
					</div>
					<div class="btn-add">
						<input type="submit" value="Add Tour">
					</div>
				</form>
			</div>
			<div id="responseDiv"></div>
		</div>
	</div>

	<script type="text/javascript" src="js/jquery-1.9.0.js"></script>	
	<script type="text/javascript" src="js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="js/messages_vi.js"></script>
	<script type="text/javascript">
        jQuery(document).ready(function() {
                jQuery("#ajaxButton").click(function() {
                        jQuery.ajax({
                                type : "POST",
                                url : "help.jsp",
                                success : function(html) {
                                        jQuery("#responseDiv").html(html);
                                }
                        });
                });
        });
</script>
	<script type="text/javascript">
	$(document).ready(function(){
		$("#input_form").validate({
	        rules: {
	        	
	    		username: {
	    	  		required: true,
	    	  	},
	    	  	
	    		password: {
	    	  		required: true,
	    	  	},
	    	  	
				repassword: {
					equalTo: "#password" // So sánh trường cpassword với trường có id là password
				},
	        	//First name must be characters and not contain number
	    		firstname: {
	    	  		required: true,
	    	  		maxlength: 20
	    	  	},
	    	  	//Last name must be characters and not contain number
	    	  	lastname: {
	    	  		required: true,
	    	  		maxlength: 20
	    	  	},
	    	  	//Must be number
	    	  	telephone: {
	    	  		maxlength: 11,
	    	  		number: true
	    	  	},
	    	  	//Must be [a..Z][0..9]@[a..Z].
	    	  	email: {
	    	  		maxlength: 50,
	    	  		email: true
	    	  	},
	    	  	description: {
	                maxlength: 200
	    	  	},
	        }, 
	        messages: {
	        	username: {
	    	  		required: "User name must be a string",
	    	  	},
	    	  	password: {
	    	  		required: "Password isn't empty !",
	    	  	},    	  	
	        	firstname: {
	    	  		required: "First name must be a string",
	    	  	},
	    	  	lastname: {
	    	  		required: "Last name must be a string",
	    	  	},
	    	  	telephone: {
	    	  		required: "Please fill in this field",
	    	  	},
	    	  	email: {
	    	  		required: "Please fill in this field",
	    	  	},
	    	  	description:{
	    	  		required: "Please fill in this field",
	    	  	}
	        }
	    }); 
	})
	
	function checkAll() {
		var username = document.formRegister.username.value;
		var firstname = document.formRegister.firstname.value;
		var lastname = document.formRegister.lastname.value;
		var email = document.formRegister.email.value;
		var n;
		if (firstname == "") {
			alert(" invalid firstname");
			return false;
		}
		n = firstname.length;
		while ( n > 0) {
			if (firstname.charAt(n-1) > '0' && firstname.charAt(n-1) < '9') {
				alert(" firstname khong duoc chu ky tu so: " + firstname.charAt(n-1));
				return false;
			}
			n--;
		}
		
		n = lastname.length;
		while ( n > 0) {
			if (lastname.charAt(n-1) > '0' && lastname.charAt(n-1) < '9') {
				alert(" lastname khong duoc chu ky tu so: " + lastname.charAt(n-1));
				return false;
			}
			n--;
		}
		if ($('input[name=area]:checked').length <= 0) {
		    alert(" You must to select a area");
		    return false;
		}
		
		var rs = new RegExp("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
		if(!email.match(rs)) {
			alert(" invalid email");
			return false;
		}
	}
	
	</script>
</body>
</html>